{% extends 'bootstrap-modal-layout.html.twig' %}

{% set modal_class = 'modal-lg' %}

{% set replaceFor= replaceFor|default(null) %}

{% do script(['app/js/question-manage/picker/index.js']) %}

{% block title %}{% if replaceFor %}{{'course.testpaper_manage.question.replace_modal.replace'|trans}}{% else %}{{'course.testpaper_manage.question.replace_modal.select'|trans}}{% endif %}{% endblock %}

{% block body %}
<div id="question-picker-body">

  {% include 'question-manage/picker-search-form.html.twig' %}

  <table class="table table-condensed" id="item-picker-table">
    <thead>
    <tr>
      {% if not replace|default(null) %}
        <th><input type="checkbox" data-role="batch-select"></th>
      {% endif %}
      <th width="45%">{{'course.testpaper_manage.question.stem'|trans}}</th>
      <th>{{'course.testpaper_manage.question.type'|trans}}</th>
      {% if targetType|default('testpaper') == 'testpaper' %}
        <th>{{'course.testpaper_manage.question.score'|trans}}</th>
      {% endif %}
      <th>{{'course.testpaper_manage.question.operation'|trans}}</th>
    </tr>
    </thead>
    <tbody>
      {% for question in questions if (question.type != 'material' or question.subCount > 0) %}
        {% include 'question-manage/question-pick-tr.html.twig' %}
      {% else %}
        <tr>
          <td colspan="20"><div class="empty">{{'course.testpaper_manage.question.replace_modal.empty'|trans}}<a class="link-primary" href="{{ path('course_set_manage_question',{id:courseSet.id}) }}">{{'course.testpaper_manage.question.replace_modal.create_btn'|trans}}</a></div>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  {% if not replace %}
    <div id="item-operate">
      <label class="checkbox-inline">
        <input type="checkbox" data-role="batch-select">{{'course.testpaper_manage.question.replace_modal.select_all_btn'|trans}}
      </label>
    </div>
  {% endif %}
  {{ web_macro.paginator(paginator) }}
</div>

{% endblock %}

{% block footer %}
    <span class="color-danger pull-left js-choice-notice" style="display:none;">{{'course.testpaper_manage.question.replace_modal.select_btn'|trans}}</span>
    <button type="button" class="btn btn-primary" type="button" class="btn btn-primary pull-right" data-role="batch-select-save" data-toggle="form-submit" data-target="#block-form" data-url="{{ path('course_set_manage_question_picked', {courseSetId:courseSet.id }) }}">{{'form.btn.confirm'|trans}}</button>

    <button type="button" class="btn btn-link pull-right" data-dismiss="modal">{{'form.btn.close'|trans}}</button>
{% endblock %}
